import { GSprite } from "../../../../../com/mui/controls/GSprite";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { ObjCreate } from "../../common/ObjCreate";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { CrossGuildWarChooseForTopBtnData } from "../data/CrossGuildWarChooseForTopBtnData";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { GLoadedButton } from "../../../../../com/mui/controls/GLoadedButton";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
//class CrossGuildWarChooseForTopBtnRender
    
    export  class CrossGuildWarChooseForTopBtnRender extends GSprite
    {
        constructor(arg1: string)
        {
            super();
            this._sp = new Object /* flash.display.Sprite */();
            this._resName = arg1;
            this._btn.addEventListener(flash.events.MouseEvent.CLICK, this.clickBtnHandler);
            return;
        }

        /* internal  */clickBtnHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.CrossGuildWarClickTopXBtn, this._data));
            return;
        }

        protected /* override */ createDisposedChildrenImpl(): void
        {
            super.createDisposedChildrenImpl();
            this.addChild(this._sp);
            this._btn = ObjCreate.createGLoadedButton(this._resName, 0, 0, 141, 79, this._sp);
            var loc1=GlobalStyle.textFormat1;
            loc1.align = flash.text.TextFormatAlign.CENTER;
            loc1.size = 14;
            this._txtDesc = ObjCreate.createGTextField("", 0, 46, 141, 20, this._sp, loc1);
            this._txtDesc.mouseEnabled = false;
            return;
        }

        public updateData(arg1: CrossGuildWarChooseForTopBtnData): void
        {
            if (arg1 == null) 
            {
                return;
            }
            this._data = arg1;
            this._txtDesc.htmlText = arg1.descHtml;
            if (arg1.isClickable) 
            {
                this._btn.mouseEnabled = true;
                this._btn.filters = [];
            }
            else 
            {
                this._btn.mouseEnabled = false;
                this._btn.filters = [FilterConst.colorFilter];
            }
            if (arg1.isSelected) 
            {
                this.filters = [FilterConst.crossGuildWarStageBtnFilter];
            }
            else 
            {
                this.filters = [];
            }
            if (arg1.isCurIndex) 
            {
                var loc1;
                this._sp.scaleY = loc1 = 1.04;
                this._sp.scaleX = loc1;
                this._sp.x = -3;
                this._sp.y = -3;
            }
            else 
            {
                this._sp.scaleY = loc1 = 1;
                this._sp.scaleX = loc1;
                this._sp.x = 0;
                this._sp.y = 0;
            }
            return;
        }

        /* internal */ /* var */_resName: string;

        /* internal */ /* var */_btn: GLoadedButton;

        /* internal */ /* var */_txtDesc: GTextFiled;

        /* internal */ /* var */_sp: Object /* flash.display.Sprite */;

        /* internal */ /* var */_data: CrossGuildWarChooseForTopBtnData;
    }
